package com.qfedu.openapi.web.master.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qfedu.openapi.web.master.dao.clientuser.ClientUserDao;
import com.qfedu.openapi.web.master.entity.ClientUser;
import com.qfedu.openapi.web.master.service.ClientUserService;
import com.qfedu.openapi.web.master.vo.PageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("/clientUserService")
@Transactional
public class ClientUserServiceImpl implements ClientUserService {
    @Autowired
    private ClientUserDao clientUserDao;

    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public ClientUser findClientUserById(Integer id) {
        return clientUserDao.findClientUserById(id);
    }

    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public PageInfo<ClientUser> findAllClientUser(PageVo pageVo) {
        PageHelper.startPage(pageVo.getPage(),pageVo.getLimit());
        List<ClientUser> ClientUsers = clientUserDao.findAllClientUser();
        return new PageInfo<ClientUser>(ClientUsers);
    }

    @Override
    public PageInfo<ClientUser> findAllClientUser(PageVo pageVo, ClientUser clientUser) {
        PageHelper.startPage(pageVo.getPage(),pageVo.getLimit());
        List<ClientUser> ClientUsers = clientUserDao.findAllClientUsersByCondition(clientUser);
        return new PageInfo<ClientUser>(ClientUsers);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Integer addClientuser(ClientUser clientUser) {
        return clientUserDao.insertClientuser(clientUser);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Integer delClientuser(Integer[] ids) {
        return clientUserDao.deleteClientuser(ids);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Integer updateClientuser(ClientUser clientUser) {
        return clientUserDao.updateClientuser(clientUser);
    }
}
